Deavmi's coding shack
new_docs/content/documentation/structs.md 863266e41e66ad974830880ee2f006d6f8e42a65 (863266e4) Text, 859 B
title: Structs
tags: [structs]
date: 2021-05-31
Introduction
What are structs? In T a Struct is a user-defined type which associates several fields toghether however, unlike C, structs in T can have a set of functions associated with them as well.
The syntax for declaring a struct with name T383838<name>, and some fields T383838<field1>, T383838<field2> with the types T383838<type1>, T383838type2> respectively is as follows:
T282828
struct <name>
{
<type1> <field1>;
<type2> <field2>;
}
Note: Assignments to these variables within the struct's body is not allowed.
Example
Perhaps we want a simple struct that associates a name, age and gender together to represent a Person, then we can declare such a struct as follows:
T282828
struct Person
{
char* name;
ubyte age;
ubyte gender;
}
Member functions
TODO: Add this
Example
Served by rngit 1.5.0 - Generated in 0.12s